import { defineStore } from 'pinia';
import { ANY_OBJECT } from '@/types/generic';

export default defineStore('message', {
  state: () => {
    return {
      messageTimer: undefined as number | undefined,
      messageCount: {} as ANY_OBJECT,
    };
  },
  actions: {
    setMessageTimer(timer: number) {
      this.messageTimer = timer;
    },
    setMessageCount(data: ANY_OBJECT) {
      //console.log('setMessageCount >>>', data);
      if (data) {
        data.totalCount = data.copyMessageCount + data.remindingMessageCount;
      }
      this.messageCount = data;
    },
    // 获得消息列表数据
    loadMessage() {
      // TODO: 获取消息列表
    },
    startMessage() {
      // TODO: 开始消息获取轮询
    },
    stopMessage() {
      // TODO: 结束消息获取轮询
    },
    reloadMessage() {
      this.loadMessage();
    },
  },
});
